Skip to content

Produces empty LCOV files since v0.9.0 #1333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Minoru opened this issue Apr 16, 2025 · 8 comments · May be fixed by #1359
Open

Produces empty LCOV files since v0.9.0 #1333

Minoru opened this issue Apr 16, 2025 · 8 comments · May be fixed by #1359

Comments

@Minoru
Copy link
Contributor

Minoru commented Apr 16, 2025

On Linux x86_64, I am getting the following LCOV file instead of the usual 920K of content:

TN:

Bisect results:

There are only 'skip'ped commits left to test.
The first bad commit could be any of:
ea325bdcffd4ccfd2692a5781b758d637202e4bf
16ee717f0e136cf3dea16649ad41c8485309cf8a
We cannot bisect more!

I had to git bisect skip the ea325bd because it panicked:

20:15:36 [ERROR] A panic occurred at src/llvm_tools.rs:94: called `Result::unwrap()` on an `Err` value: Error { kind: UnexpectedEof, message: "failed to fill whole buffer" }

I guess it was running into a file that's smaller than 128 bytes (in that commit, grcov used read_exact()).

The command line is:

grcov . --source-dir . --binary-path . --ignore-not-existing --ignore='/*' --ignore='3rd-party/*' --ignore='doc/*' --ignore='test/*' --ignore='target/*' --ignore='newsboat.cpp' --ignore='podboat.cpp' -t lcov -o coverage.lcov

I don't have a minimal reproducer yet (ran out of screen time for today), but it looks like the switch to infer crate broke some logic in grcov.

Minoru added a commit to newsboat/newsboat that referenced this issue Apr 16, 2025
Minoru added a commit to newsboat/newsboat that referenced this issue Apr 16, 2025
@marco-c
Copy link
Collaborator

marco-c commented Apr 22, 2025

@Minoru could you check with/without the two commits to figure out exactly which of the two is causing this?
If you can also have a minimal reproducer it would be ideal.

@tugtugtug
Copy link

tugtugtug commented May 24, 2025

Seeing the similar issue, empty outputs. I think it has to do with the silent auto inclusion of the gitignore file, which is intended to not allow submitting suff, but auto ignoring contents in that file makes no sense, as the binaries produced are obviously excluded from git submissions. deleting the .gitignore works. This is certainly a regression, .gitignore should not be automatically loaded.

0.8.24

$ ./grcov . --source-dir src --ignore "*cargo/registry/*" --ignore "/rustc/*" --branch --binary-path target/release/deps/ --output-types cobertura,html --output-path coverage --log-level DEBUG
03:43:42 [DEBUG] (1) globset: glob converted to regex: Glob { glob: "*cargo/registry/*", re: "(?-u)^.*cargo/registry/.*$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('c'), Literal('a'), Literal('r'), Literal('g'), Literal('o'), Literal('/'), Literal('r'), Literal('e'), Literal('g'), Literal('i'), Literal('s'), Literal('t'), Literal('r'), Literal('y'), Literal('/'), ZeroOrMore]) }
03:43:42 [DEBUG] (1) globset: built glob set; 0 literals, 0 basenames, 0 extensions, 1 prefixes, 0 suffixes, 0 required extensions, 1 regexes

0.9.0

$ ./grcov . --source-dir src --ignore "*cargo/registry/*" --ignore "/rustc/*" --branch --binary-path target/release/deps/ --output-types cobertura,html --output-path coverage --log-level DEBUG
03:44:55 [DEBUG] (6) ignore::gitignore: opened gitignore file: /test/.gitignore
03:44:55 [DEBUG] (6) globset: glob converted to regex: Glob { glob: "**/target/**/*", re: "(?-u)^(?:/?|.*/)target(?:/|/.*/)[^/]*$", opts: GlobOptions { case_insensitive: false, literal_separator: true, backslash_escape: true, empty_alternates: false }, tokens: Tokens([RecursivePrefix, Literal('t'), Literal('a'), Literal('r'), Literal('g'), Literal('e'), Literal('t'), RecursiveZeroOrMore, ZeroOrMore]) }
03:44:55 [DEBUG] (6) globset: glob converted to regex: Glob { glob: "istio-*/**/*", re: "(?-u)^istio\\-[^/]*(?:/|/.*/)[^/]*$", opts: GlobOptions { case_insensitive: false, literal_separator: true, backslash_escape: true, empty_alternates: false }, tokens: Tokens([Literal('i'), Literal('s'), Literal('t'), Literal('i'), Literal('o'), Literal('-'), ZeroOrMore, RecursiveZeroOrMore, ZeroOrMore]) }
03:44:55 [DEBUG] (6) globset: built glob set; 0 literals, 2 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 2 regexes
03:44:55 [DEBUG] (6) ignore::gitignore: opened gitignore file: /test/.git/info/exclude
03:44:55 [DEBUG] (6) ignore::walk: ignoring target/release/deps/memchr-d3c92593497a8663.d: Ignore(IgnoreMatch(Gitignore(Glob { from: Some("/test/.gitignore"), original: "**/target/**", actual: "**/target/**/*", is_whitelist: false, is_only_dir: false })))
...
$ cat coverage/cobertura.xml
<?xml version="1.0"?><!DOCTYPE  coverage SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-04.dtd'><coverage lines-covered="0" lines-valid="0" line-rate="0" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0" version="1.9" timestamp="1748058295"><sources><source>/test/transform-filter/src</source></sources><packages></packages></coverage

@tugtugtug
Copy link

tugtugtug commented May 24, 2025

@marco-c it is 16ee717, which introduced the ignore dependency.

@marco-c
Copy link
Collaborator

marco-c commented May 28, 2025

@tugtugtug thanks for investigating. It should just be a matter of calling https://docs.rs/ignore/latest/ignore/struct.WalkBuilder.html#method.standard_filters on the WalkBuilder to set them to false.
It'd be great if you could test that and submit a PR!

@tugtugtug
Copy link

@tugtugtug thanks for investigating. It should just be a matter of calling https://docs.rs/ignore/latest/ignore/struct.WalkBuilder.html#method.standard_filters on the WalkBuilder to set them to false. It'd be great if you could test that and submit a PR!

I'm a bit confused tho, @marco-c so we end up with the standard filters disabled for the WalkBuilder, and do not really ignore anything? So isn't the ignore dependency overkill for what we need? which is probably achievable already with rayon (which is part of the dependencies already)?

@marco-c
Copy link
Collaborator

marco-c commented May 29, 2025

The only reason for using ignore is to have parallel walk of directories. We could implement it manually, but it would be quite some effort compared to just using ignore.

@marco-c
Copy link
Collaborator

marco-c commented May 29, 2025

I mean, I'd likely* accept a PR to implement parallel walking directly in grcov without ignore, but we can just fix this bug quickly for now by setting that option to false.

* unless it is too much code and too complex code

tugtugtug pushed a commit to tugtugtug/grcov that referenced this issue May 29, 2025
…1333

While ignore is great for collecting files while applying certain
auto filters, it barely provides anything that is used by this tool.
All we needed was a way to process the binary file searches in parallel.

- Implemented a simple parallel file walker uses Rayon to parallize the
  file search.
- Added tests to cover the new implementation
- Compared the benchmarks with ignore, and the new implementation performs
  better consistently on my setup (Apple M4 Max).
tugtugtug pushed a commit to tugtugtug/grcov that referenced this issue May 29, 2025
…1333

While ignore is great for collecting files while applying certain
auto filters, it barely provides anything that is used by this tool.
All we needed was a way to process the binary file searches in parallel.

- Implemented a simple parallel file walker uses Rayon to parallelize the
  file search.
- Added tests to cover the new implementation
- Compared the benchmarks with ignore, and the new implementation performs
  better consistently on my setup (Apple M4 Max).
- Verified this fixed the empty outputs for people running grcov with a
  .gitignore that includes the output folder.
tugtugtug added a commit to tugtugtug/grcov that referenced this issue May 29, 2025
…1333

While ignore is great for collecting files while applying certain
auto filters, it barely provides anything that is used by this tool.
All we needed was a way to process the binary file searches in parallel.

- Implemented a simple parallel file walker uses Rayon to parallelize the
  file search.
- Added tests to cover the new implementation
- Compared the benchmarks with ignore, and the new implementation performs
  better consistently on my setup (Apple M4 Max).
- Verified this fixed the empty outputs for people running grcov with a
  .gitignore that includes the output folder.
tugtugtug added a commit to tugtugtug/grcov that referenced this issue May 29, 2025
…1333

While ignore is great for collecting files while applying certain
auto filters, it barely provides anything that is used by this tool.
All we needed was a way to process the binary file searches in parallel.

- Implemented a simple parallel file walker uses Rayon to parallelize the
  file search.
- Added tests to cover the new implementation
- Compared the benchmarks with ignore, and the new implementation performs
  better consistently on my setup (Apple M4 Max).
- Verified this fixed the empty outputs for people running grcov with a
  .gitignore that includes the output folder.
@tugtugtug
Copy link

@marco-c hopefully, this change fits in the not "too much code" category. The walker implementation is less than 150 lines. All tests passed in the PR, and I verified with the benchmarks on my mac, it performs slightly better than the original ignore lib with the standard filter disabled.

tugtugtug added a commit to tugtugtug/grcov that referenced this issue May 29, 2025
…1333

While ignore is great for collecting files while applying certain
auto filters, it barely provides anything that is used by this tool.
All we needed was a way to process the binary file searches in parallel.

- Implemented a simple parallel file walker uses Rayon to parallelize the
  file search.
- Added tests to cover the new implementation
- Compared the benchmarks with ignore, and the new implementation performs
  better consistently on my setup (Apple M4 Max).
- Verified this fixed the empty outputs for people running grcov with a
  .gitignore that includes the output folder.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants